import requests


class addRmpApi(object):
    def add_emp(self,req_header, req_body):
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/user",
                             headers=req_header,
                             json=req_body)
        return resp


if __name__ == '__main__':
    emp = addRmpApi()
    # 获取令牌
    resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/login",
                         json={"mobile": "13800000002", "password": "123456"})
    token = resp.json().get("data")

    req_header = {"Content-Type": "application/json", "Authorization": token}

    req_body = {"username": "张三", "mobile": "15145678901", "workNumber": "013"}
    resp = emp.add_emp(req_header, req_body)
    print(resp.json())
